﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wedn.Core.Entity;
using Wedn.Core.Service;

namespace Wedn.Web.UI.Admin.Include
{
    public partial class Writer : AdminInclude
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Thread.Sleep(3000);
        }
        protected string GetCategoryList()
        {
            TermManager termManager = new TermManager();
            List<Term> categoryList = termManager.GetTermList(Core.Common.TermType.PostCategory);
            StringBuilder sbd = new StringBuilder();
            string format = "<li class=\"level-{0}\"><label><input type=\"checkbox\" class=\"post-category\" value=\"{1}\" />{2}</label></li>";
            foreach (var item in categoryList)
            {
                int level = 0;
                int pid = item.ParentId;
                while (pid != 0)
                {
                    level++;
                    pid = categoryList.Find((cat) => { return cat.Id == pid; }).ParentId;
                }
                sbd.AppendFormat(format, level, item.Id, item.Name);
            }
            return sbd.ToString();
        }
    }
}